﻿using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using System.Data;
using System.Data.SqlClient;

namespace DAO
{
    public class ChooseDAO
    {
        public static List<BacSiDTO> SelectTenBacSiByAll()
        {
            List<BacSiDTO> list = new List<BacSiDTO>();
            try
            {
                // Create List Sql Parameter
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                DataTable dt = SqlDataAccessHelper.ExecuteQuery("usp_SelectBacSiAll", sqlParams);
                foreach (DataRow dr in dt.Rows)
                {
                    BacSiDTO bacsi = new BacSiDTO();
                    bacsi.Ma = int.Parse(dr["Ma"].ToString());
                    bacsi.Hoten = dr["HoTen"].ToString();
                    list.Add(bacsi);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return list;
        }

        public static List<NgheNghiepDTO> SelectTenNgheNghiepByAll()
        {
            List<NgheNghiepDTO> list = new List<NgheNghiepDTO>();
            try
            {
                // Create List Sql Parameter
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                DataTable dt = SqlDataAccessHelper.ExecuteQuery("usp_SelectDanhMucNgheNghiepsAll", sqlParams);
                foreach (DataRow dr in dt.Rows)
                {
                    NgheNghiepDTO nghenghiep = new NgheNghiepDTO();
                    nghenghiep.Ma = int.Parse(dr["Ma"].ToString());
                    nghenghiep.Ten = dr["Ten"].ToString();
                    list.Add(nghenghiep);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return list;
        }

        public static List<DichVuDTO> SelectTenDichVuByAll()
        {
            List<DichVuDTO> list = new List<DichVuDTO>();
            try
            {
                // Create List Sql Parameter
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                DataTable dt = SqlDataAccessHelper.ExecuteQuery("usp_SelectDanhMucDichVusAll", sqlParams);
                foreach (DataRow dr in dt.Rows)
                {
                    DichVuDTO dichvu = new DichVuDTO();
                    dichvu.Ma = int.Parse(dr["Ma"].ToString());
                    dichvu.Ten = dr["Ten"].ToString();
                    list.Add(dichvu);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return list;
        }

        public static List<QuanDTO> SelectTenQuanByAll()
        {
            List<QuanDTO> list = new List<QuanDTO>();
            try
            {
                // Create List Sql Parameter
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                DataTable dt = SqlDataAccessHelper.ExecuteQuery("usp_SelectQuansAll", sqlParams);
                foreach (DataRow dr in dt.Rows)
                {
                    QuanDTO quan = new QuanDTO();
                    quan.Ma = int.Parse(dr["Ma"].ToString());
                    quan.Ten = dr["Ten"].ToString();
                    list.Add(quan);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return list;
        }

        public static List<LoaiBenhNhanDTO> SelectTenLoaiBenhNhanByAll()
        {
            List<LoaiBenhNhanDTO> list = new List<LoaiBenhNhanDTO>();
            try
            {
                // Create List Sql Parameter
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                DataTable dt = SqlDataAccessHelper.ExecuteQuery("usp_SelectDanhMucLoaiBenhNhansAll", sqlParams);
                foreach (DataRow dr in dt.Rows)
                {
                    LoaiBenhNhanDTO loaibn = new LoaiBenhNhanDTO();
                    loaibn.Ma = int.Parse(dr["Ma"].ToString());
                    loaibn.Ten = dr["Ten"].ToString();
                    list.Add(loaibn);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return list;
        }

        public static DataTable SelectAllDotDieuTriByMaBenhNhan(int ma)
        {
            DataTable dt = new DataTable();
            try
            {
                // Create List Sql Parameter
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                sqlParams.Add(new SqlParameter(@"Ma", ma));
                dt = SqlDataAccessHelper.ExecuteQuery("usp_SelectAllDotDieuTriByMaBenhNhan", sqlParams);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public static DataTable SelectAllDMDichVu()
        {
            DataTable dt = new DataTable();
            try
            {
                // Create List Sql Parameter
                List<SqlParameter> sqlParams = new List<SqlParameter>();
                dt = SqlDataAccessHelper.ExecuteQuery("usp_SelectDanhMucDichVusAll", sqlParams);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }
    }
}
